<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <!-- <el-button type="primary" @click="onAddClicked">link.add</el-button> -->
    <el-button type="primary" @click="onListClicked">link.list</el-button>
    <el-button type="primary" @click="onTablesClicked">mysql.tables</el-button>
    <el-button type="primary" @click="onColumnClicked">mysql.columns</el-button>
  </div>
</template>

<script>
import IPC from "../background/ipc";
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  methods: {
    onAddClicked() {
      IPC.invoke("link.add", {
        linkInfo: {
          name: "五菱数据库",
          host: "10.1.124.94",
          port: "3306",
          user: "psim",
          password: "pyMFu6F@SfYtgQe",
          database: "psim",
        },
      }).then((result) => {
        console.log(result);
      });
    },
    onListClicked() {
      IPC.invoke("link.list", { like: "" }).then((result) => {
        console.log(result);
      });
    },
    onTablesClicked() {
      IPC.invoke("mysql.tables", {
        linkId: "f79fd916b3309ca51befa2407f307f95",
        like: "eodp",
      }).then((result) => {
        console.log(result);
      });
    },
    onColumnClicked() {
      IPC.invoke("mysql.columns", {
        linkId: "f79fd916b3309ca51befa2407f307f95",
        tableId: "4226228b928391f86cad2ba9314de100",
      }).then((result) => {
        console.log(result);
      });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
